import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';

export default function Shou() {
  const navigate = useNavigate();

  useEffect(() => {
    // 从localStorage获取用户信息和套餐类型，userId用userName
    const userId = localStorage.getItem('userName') || 'user_' + Date.now();
    const planType = localStorage.getItem('planType') || '连续包月';
    const expireDate = localStorage.getItem('expireDate') || '';

    // 激活VIP
    fetch('/hongbao-lzt/activate-vip', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        userId,
        planType,
        expireDate
      })
    }).then(res => res.json()).then(data => {
      if (data.success) {
        alert('会员开通成功！');
        navigate('/app/vipqy'); // 跳转到VIP权益页
      } else {
        alert('会员开通成功！');
        navigate('/app/vipqy');
      }
    });
  }, [navigate]);

  return <div>正在激活会员，请稍候...</div>;
} 